using Android.Database.Sqlite;
using Android.Content;

namespace CapstoneProject.DataAccess
{
    public class AccountDatabaseHelper : SQLiteOpenHelper
    {
        private const string DATABASE_NAME = "CapstoneDB2.1";
        private const int DATABASE_VERSION = 1;

        public AccountDatabaseHelper(Context context)
            : base(context, DATABASE_NAME, null, DATABASE_VERSION)
        {
        }

        public override void OnCreate(SQLiteDatabase db)
        {
            db.ExecSQL(@"CREATE TABLE Account(AccountId INTEGER PRIMARY KEY AUTOINCREMENT, 
                                                Username TEXT NOT NULL, 
                                                Password TEXT NOT NULL,
                                                FiUrl TEXT NOT NULL,
                                                FiOrg TEXT NOT NULL,
                                                Fid TEXT NOT NULL,
                                                BankAccountId TEXT NOT NULL,
                                                BankId TEXT NOT NULL,
                                                AccountName TEXT NOT NULL,
                                                UserId INTEGER NOT NULL,
                                                Balance DOUBLE(4,2) NOT NULL
            )");
        }

        public override void OnUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
        {
            db.ExecSQL("DROP TABLE IF EXISTS Account");

            OnCreate(db);
        }
    }
}